<!--  -->
<template>
  <div class='xgmc'>
       <van-nav-bar
      title="修改昵称"
      left-text="返回"
      
      @click-left="$router.back()"
    />
    <van-field v-model="value" label="昵称" placeholder="请输入昵称" />
    <van-button type="primary" size="large" @click="onxiugai">确认修改</van-button>
  </div>
</template>

<script>
import { mapState ,mapMutations} from "vuex";
import { xiugainicheng } from "network/api.js";
export default {
name:'',
  data () {
    return {
        value:''
    };
  },


  computed: {
      ...mapState(['userInfo'])
  },


  methods: {
      ...mapMutations(["changniche"]),
      async onxiugai(){
          console.log(this.value)
         const {errcode,errmsg}=await xiugainicheng(this.value)
        //  const req1=await getpxx()
        
         if(errcode!=0) return this.$toast(errmsg)
         this.changniche({nickname:this.value})
         this.$router.push('/me')
      }
  },
  created(){
      this.value=this.userInfo.nickname 
  }
}

</script>
<style lang='less' scoped>
</style>